package com.aiobc.business.personalcenter.contoller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.aiobc.business.personalcenter.domain.DataCommentLog;
import com.aiobc.business.personalcenter.service.DataCommentLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aiobc.common.log.annotation.Log;
import com.aiobc.common.log.enums.BusinessType;
import com.aiobc.common.security.annotation.PreAuthorize;

import com.aiobc.common.core.web.controller.BaseController;
import com.aiobc.common.core.web.domain.AjaxResult;
import com.aiobc.common.core.utils.poi.ExcelUtil;
import com.aiobc.common.core.web.page.TableDataInfo;

/**
 * 数据评论记录Controller
 * 
 * @author ruoyi
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/comment")
public class DataCommentLogController extends BaseController
{
    @Autowired
    private DataCommentLogService dataCommentLogService;

    /**
     * 查询数据评论记录列表
     */
    @PreAuthorize(hasPermi = "system:log:list")
    @GetMapping("/list")
    public TableDataInfo list(DataCommentLog dataCommentLog)
    {
        startPage();
        List<DataCommentLog> list = dataCommentLogService.selectDataCommentLogList(dataCommentLog);
        return getDataTable(list);
    }

    /**
     * 导出数据评论记录列表
     */
    @PreAuthorize(hasPermi = "system:log:export")
    @Log(title = "数据评论记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataCommentLog dataCommentLog) throws IOException
    {
        List<DataCommentLog> list = dataCommentLogService.selectDataCommentLogList(dataCommentLog);
        ExcelUtil<DataCommentLog> util = new ExcelUtil<DataCommentLog>(DataCommentLog.class);
        util.exportExcel(response, list, "数据评论记录数据");
    }

    /**
     * 获取数据评论记录详细信息
     */
    @PreAuthorize(hasPermi = "system:log:query")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") String logId)
    {
        return AjaxResult.success(dataCommentLogService.selectDataCommentLogById(logId));
    }

    /**
     * 新增数据评论记录
     */
    @PreAuthorize(hasPermi = "system:log:add")
    @Log(title = "数据评论记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataCommentLog dataCommentLog)
    {
        return toAjax(dataCommentLogService.insertDataCommentLog(dataCommentLog));
    }

    /**
     * 修改数据评论记录
     */
    @PreAuthorize(hasPermi = "system:log:edit")
    @Log(title = "数据评论记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataCommentLog dataCommentLog)
    {
        return toAjax(dataCommentLogService.updateDataCommentLog(dataCommentLog));
    }

    /**
     * 删除数据评论记录
     */
    @PreAuthorize(hasPermi = "system:log:remove")
    @Log(title = "数据评论记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable String[] logIds)
    {
        return toAjax(dataCommentLogService.deleteDataCommentLogByIds(logIds));
    }
}
